/**
 * @param {number[]} changed
 * @return {number[]}
 */
 var findOriginalArray = function(changed) {
  const n = changed.length
  if(n % 2 !== 0){
    return []
  }
  const map = new Map()
  for(const num of changed){
    map.set(num, map.has(num) ? map.get(num) + 1 : 1)
  }
  changed.sort((a,b) => a-b)
  const ret = []
  for(const num of changed){
    if(map.get(num) === 0){
      continue
    }
    if(num === 0){
      if(map.get(0) % 2 !== 0){
        return []
      }
      ret.push(...new Array(map.get(0)/2).fill(0))
      map.set(0, 0)
      continue
    }
    if(map.has(num * 2) && map.get(num * 2) > 0){
      ret.push(num)
      map.set(num * 2, map.get(num * 2) - 1)
      map.set(num, map.get(num) - 1)
    }else{
      return []
    }
  }
  
  return ret
};